<?php 
class CProductattr extends Zend_Db_Table
{
	protected $_name;
	protected $_primary;
	public function __construct()
	{
		$this->_name=R_PRE. "product_attr";
		parent::__construct();
	}
	
	public function updateAttr($data)
	{
		$row = $this->fetchRow(array('itemid = ?'=>$data['itemid'], 'attr_name = ?'=>$data['attr_name']));
		if ($row) {
			unset($data['itemid']);
			unset($data['attr_name']);
			
			return $this->update($data, 'attr_id = ' . $row->attr_id);
		} else {
			return $this->insert($data);
		}
	}
	
	public function getAttr($itemid, $attrId)
	{
		return $this->fetchRow(array('itemid = ?'=>$itemid, 'attr_id_ex = ?'=>$attrId));
	}
		
}